import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {${entity}Form, ${entity}Query} from "@/api/${table.entityPath?replace("sys","")?uncap_first}/types";

/**
* ${table.comment}数据
*
* @param queryParams
*/
export function get${entity}Page(
queryParams: ${entity}Query
): AxiosPromise<PageResult<[]>> {
return request({
url: '/api/v1/${table.entityPath?replace("sys","")?uncap_first}/page',
method: 'get',
params: queryParams
});
}


/**
* 获取${table.comment}表单数据
*
* @param queryParams
*/
export function get${entity}Form(id: number): AxiosPromise<${entity}Form> {
    return request({
    url: '/api/v1/${table.entityPath?replace("sys","")?uncap_first}/' + id + '/form',
    method: 'get'
    });
    }

    /**
    * 保存${table.comment}
    *
    * @param data
    */
    export function save${entity}(data: ${entity}Form) {
    return request({
    url: "/api/v1/${table.entityPath?replace("sys","")?uncap_first}",
    method: "post",
    data: data,
    });
    }

    /**
    * 删除${table.comment}
    *
    * @param ids
    */
    export function delete${entity}(ids: string) {
        return request({
        url: '/api/v1/${table.entityPath?replace("sys","")?uncap_first}/' + ids,
        method: 'delete'
        });
    }

    /**
    * 导入${table.comment!}
    *
    * @param file
    */
    export function import${entity}(file: any) {
        const formData = new FormData();
        formData.append('file', file);
        return request({
            url: '/api/v1/${table.entityPath?replace("sys","")?uncap_first}/${entity?uncap_first}Import',
            method: 'post',
            data: formData,
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    }

    /**
    * 导出${table.comment!}
    *
    * @param ids
    * @returns
    */
    export function export${entity}(ids: any) {
        return request({
            url: '/api/v1/${table.entityPath?replace("sys","")?uncap_first}/_export?ids='+ids,
            method: 'get',
            responseType: 'arraybuffer'
        });
    }